import random
import time

print(random.random())
print(random.randint(1,3))
alist = [1,2,3,4,5]
print(random.choice(alist))
print(random.choices(alist,k=2))
# 洗牌
random.shuffle(alist)
print(alist)
# time模块
# 休眠函数 time.sleep(5)
print("----------")
time.time() # 获取当前时间戳
# 获取当前时间的时间元组

print(time.localtime())
str1 = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
print(str1)

str2 = "2000-03-12 00:00:00"
timeTuple = time.strptime(str2, "%Y-%m-%d %H:%M:%S")
print(timeTuple)


# 大乐透案例：
    # 生成一个大乐透彩票投注，大乐透号码分为红区和蓝区，红区35个数字1-35不重复，蓝区两个数字1-8不重复
# 1.从红区随机获取5个数字
# redlist = set()
# bluelist = set()
# while len(redlist) < 5:
#     num = random.randint(1,35)
#     redlist.add(num)
# # 2.从蓝区获取两个数字
# while len(bluelist) < 2:
#     num2 = random.randint(1,8)
#     bluelist.add(num2)
# print(redlist,bluelist)
# # 合并两个集合,先转为有序列表
# redlist = list(redlist)
# bluelist = list(bluelist)
# alist = redlist + bluelist
# print(alist)
redlist = []
bluelist = []
while len(redlist) < 5:
    num = random.randint(1,35)
    if num in redlist:
        continue
    else:
        redlist.append(num)
print(redlist)
while len(bluelist) < 2:
    num2 = random.randint(1,8)
    if num2 in bluelist:
        continue
    else:
        bluelist.append(num2)
print(bluelist)
totalList = redlist + bluelist
print(totalList)
# 随机生成1-100之间的30个数，不允许重复
list30 = set()
while len(list30) < 30:
    num30 = random.randint(1,100)
    list30.add(num30)
list30 = list(list30)
print(list30)